企業庫異常處理應用程序塊和日誌記錄應用程序塊在 ASP.NET 中的正確使用 (Enterprise Library Exception Handling Application Block and Logging Application Block proper use in ASP.NET)


問題描述

企業庫異常處理應用程序塊和日誌記錄應用程序塊在 ASP.NET 中的正確使用 (Enterprise Library Exception Handling Application Block and Logging Application Block proper use in ASP.NET)

I have a grasp on this application block with ASP.NET, but I feel unsure if I am coding with it properly in ASP.NET.

I've looked all over for proper examples of how to use the Enterprise Library Exception Handling Application Block, but only turn up articles for Windows Forms.

Could somebody please point me in the right direction for usage of the Enterprise Library Exception Handling Application Block with ASP.NET? (e.g. handling exceptions in classes, when to propagate exception to Application_Error in Global.asax, how to process handled and unhandled exceptions in Application_Error).

I would really like to see what other people are doing.

Code incorporating the Enterprise Library Error Handling Application Block with the Logging Application Block would also be helpful.

Thanks!


參考解法

方法 1:

Perhaps it would be better to start with your objectives and then determine how to accomplish them.

The way our team does it is to log exceptions in the Application_Error event in global.asax.  This captures all unhandled exceptions and logs them to our database.  We do not use many of the features of the Exception Handling block because we haven't identified a need for them.

方法 2:

Handling exceptions with the ELEHAB is basically the same in all types of application. You catch the error and call ExceptionPolicy.HandleException. The only difference is exactly where you put your "global" catch block. In WinForms, you might put it in the Main method. In ASP.NET, you might put it in the Application_Error event. In a Windows Service, you might put it in the background thread start method.

方法 3:

You can also try the approach and library provided in the link below

http://sites.google.com/site/spyderhoodcommunity/tech-stuff/aspnetexceptionhandlingandlogginglibrary

Exception handling block is basically for enterprise level applications. It will come with it's overheads in terms of performance as well as learning curve.

If your need is simpler, the above link will provide you the architecture to do exception handling as well as the logging library.

(by 410Ken BrowningChristian HayterKartik Sehgal)

參考文件

  1. Enterprise Library Exception Handling Application Block and Logging Application Block proper use in ASP.NET (CC BY-SA 3.0/4.0)

#enterprise-library #ASP.NET #logging #exception-handling #.net






相關問題

企業庫的 Msmqdistributor 服務的優缺點是什麼? (What are pros and cons of Msmqdistributor service of Enterprise Library?)

EntLib 記錄到類別 (EntLib logging to category)

Ent Lib 4 的有效策略查看器 (Effective Policy Viewer for Ent Lib 4)

在 EntLib 中登錄/註銷 (Logging On/Off in EntLib)

使用 Wrap Handler 添加額外的異常信息 (Adding additional exception information with Wrap Handler)

將 .net 2.0 解決方案轉換為 .net 3.5 的陷阱 (Pitfalls for converting a .net 2.0 solution to .net 3.5)

System.Web.Caching與企業庫緩存塊 (System.Web.Caching vs. Enterprise Library Caching Block)

在 vs2015 中打開舊項目時企業庫引用錯誤 (Enterprise Library reference error when opening a legacy project in vs2015)

Entlib 自定義異常處理程序缺少映射 (Entlib Custom exception handler missing mappings)

您使用的是 Microsoft 企業庫嗎? (Are you using the Microsoft Enterprise Library?)

企業庫異常處理應用程序塊和日誌記錄應用程序塊在 ASP.NET 中的正確使用 (Enterprise Library Exception Handling Application Block and Logging Application Block proper use in ASP.NET)

Entlib 記錄器的模板設置 (Template settings for Entlib logger)







留言討論